﻿//-----------------------------------------------------------------------
// <copyright file="PivotTableColumn.cs" company="Forebrain Technology, LLC">
//
// Copyright (c) Forebrain Technology, LLC. All rights reserved.
// 
// This source code is released under the Microsoft Public License (Ms-PL).
//
// </copyright>
//-----------------------------------------------------------------------
namespace PivotCollectionTools.Data
{
    using System;

    /// <summary>
    /// A column in the pivot table.
    /// </summary>
    [Serializable]
    public class PivotTableColumn
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PivotTableColumn"/> class.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="category">The category.</param>
        public PivotTableColumn(string columnName, PivotTableCategory category)
        {
            this.Name = columnName;
            this.Category = category;
            this.Category.AddColumn(this);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="PivotTableColumn"/> class.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        public PivotTableColumn(string columnName)
            : this(columnName, new PivotTableCategory(columnName))
        {
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name of the pivot table column.</value>
        public string Name { get; set; }

        /// <summary>
        /// Gets the facet category.
        /// </summary>
        /// <value>The facet category of the pivot table column.</value>
        public PivotTableCategory Category { get; private set; }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            return this.Name;
        }
    }
}
